package  
org.puremvc.as3.fi.test.proxy
{
	import org.puremvc.as3.multicore.interfaces.IProxy;
	import mx.managers.IPopUpManager;
	import org.puremvc.as3.fi.patterns.proxy.Proxy;
	import org.puremvc.as3.fi.test.PureMVCTestBase;

	/**
	 * @author a.fell
	 */
	public class ProxyTest extends PureMVCTestBase 
	{
		protected var proxy : Proxy; 
		
		public function ProxyTest()
		{
			super(  );
		}
		
		override public function setUp() : void
		{
			super.setUp();
			proxy = new Proxy("Some Proxy");
		}

		override public function tearDown() : void
		{
			super.tearDown( );
			proxy = null;
		}

		public function testProxyRegistration() : void
		{
			facade.registerProxy(proxy);
			
			assertTrue(facade.hasProxy(proxy.getProxyName()));
			
			var retrieved : IProxy = facade.retrieveProxy(proxy.getProxyName());
			
			assertNotNull( retrieved );
			
			assertEquals( proxy, retrieved );
		}
		
		public function testProxyRemoval() : void
		{
			facade.registerProxy(proxy);
			
			facade.removeProxy(proxy.getProxyName());
			
			assertFalse(facade.hasProxy(proxy.getProxyName()));
			
			assertFalse( proxy.hasFacade() );
			
			assertNull( facade.retrieveProxy(proxy.getProxyName()) );
		}
		
		public function testFacadeInjection() : void
		{
			facade.registerProxy(proxy);
			
			assertTrue(proxy.hasFacade());
		}
		
	}
}
